package ro.isdc.training.jpa.misc.domain;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

public class BusinessEntityId extends DataObject {
	/**
	 * Generated Serial Version UID
	 */
	private static final long serialVersionUID = 6912246364210233646L;

	/**
	 * Entity identifier
	 */
	private long entityId = -1;

	/**
	 * The version of the entity
	 */
	private int versionNo = 0;

	/**
	 * @return the entityId
	 */
	public long getEntityId() {
		return entityId;
	}

	/**
	 * @param entityId
	 *          the entityId to set
	 */
	public void setEntityId(final long entityId) {
		this.entityId = entityId;
	}

	/**
	 * @return the versionNo
	 */
	public int getVersionNo() {
		return versionNo;
	}

	/**
	 * @param versionNo
	 *          the versionNo to set
	 */
	public void setVersionNo(final int versionNo) {
		this.versionNo = versionNo;
	}

	/**
	 * @see java.lang.Object#equals(Object)
	 */
	public boolean equals(Object object) {
		if (!(object instanceof BusinessEntityId)) {
			return false;
		}
		BusinessEntityId rhs = (BusinessEntityId) object;
		return new EqualsBuilder().append(this.versionNo, rhs.versionNo).append(
				this.entityId, rhs.entityId).isEquals();
	}

	/**
	 * @see java.lang.Object#hashCode()
	 */
	public int hashCode() {
		return new HashCodeBuilder(-1333977731, 1361292863).append(this.versionNo)
				.append(this.entityId).toHashCode();
	}

	/**
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		return new ToStringBuilder(this).append("versionNo", this.versionNo)
				.append("entityId", this.entityId).toString();
	}
}
